export default ({ editTable, orgValue, currentTreeData, roleData, userData, assignedRole,
    assignedUser }) => {

    let roles = [];
    let users = [];
    let unRoles = []; // 没有checked
    let unUsers = [];
    let searchedRoles = [...assignedRole]; // 用来存原始checked和搜索出来的所有数据
    let searchedUsers = [...assignedUser];
    roleData && roleData.rows.map((item, index) => {
        if(!assignedRole.includes(item.values['refpk'].value)) {
            searchedRoles.push(item.values['refpk'].value)
        }

        if (/^1$/.test(item.values['auth'].value)) {
            roles.push(item.values['refpk'].value);
        } else {
            unRoles.push(item.values['refpk'].value);
        }
    })
    userData && userData.rows.map((item, index) => {
        if(!assignedUser.includes(item.values['refpk'].value)) {
            searchedUsers.push(item.values['refpk'].value)
        }

        if (/^1$/.test(item.values['auth'].value)) {
            users.push(item.values['refpk'].value);
        } else {
            unUsers.push(item.values['refpk'].value)
        }
    })

    let lroles = searchedRoles.filter(pk => !unRoles.includes(pk)) // 删除不checked的
    let lusers = searchedUsers.filter(pk => !unUsers.includes(pk))
    let postData = {
        pk_rpt_def: currentTreeData
    };

    postData['roleRefpks'] = lroles.join(',');
    postData['userRefpks'] = lusers.join(',');

    if (orgValue) {
        postData['pk_org'] = orgValue.refpk;
    }

    return postData;

}